package main
import ("fmt")

func main(){
	res := plus(1,2)
	fmt.Println(res)

	res = plusPlus(1,2,3)
	fmt.Println(res)

	a,b := vals()
	fmt.Println("a:",a,"b:",b)

	c,_ := vals()
	fmt.Println("c:",c)

	sum(1,2,3,4,5)

	// 只能使用切片，不能用数组
	// nums := [3]int{1,2,3}
	nums := []int{1,2,3}
	sum(nums...)
}

func plus(a int,b int)int{
	return a + b
}

func plusPlus(a,b,c int)int{
	return a + b + c
}

// Multiple Return Values
func vals()(int,string){
	return 200,"success"
}

// Variadic Functions
func sum(nums ...int) {
	fmt.Println(nums," ")
	// []int->切片
	fmt.Printf("typeof nums:%T\n",nums)
	total := 0
	for _,num := range nums {
		total += num
	}
	fmt.Println("sum:",total)
}